import request from "@/utils/request";


/**
 * 获取工单列表
 * @param params
 * @returns {Promise<unknown>}
 */
export function getMiddleWorkOrderList(params = {}){
  return request({
    url: `/middleWorkOrder/getMiddleWorkOrderList`,
    params,
    method: 'get',
  })
}

/**
 * 获取工单详情
 * @param id
 * @returns {Promise<unknown>}
 */
export function getMiddleInfo(id){
  return request({
    url: `/middleWorkOrder/getMiddleInfo/${id}`,
  })
}

/**
 * 保存箱子数量
 * @param data
 * @returns {Promise<unknown>}
 */
export function saveMiddleGoodsNum(data){
  return request({
    url: `/middleWorkOrder/saveMiddleGoodsNum`,
    data,
    method: 'patch',
    handleError: true,
  })
}


/**
 * 确认已拣货
 * @param data
 * @returns {Promise | Promise<unknown>}
 */
export function pickedMiddleWorkOrder(data){
  return request({
    url: `/middleWorkOrder/pickedMiddleWorkOrder`,
    data,
    method: 'put',
    handleError: true,
  })
}

/**
 * 确认已送仓
 * @param id
 * @returns {Promise | Promise<unknown>}
 */
export function sendMiddle(id){
  return request({
    url: `/middleWorkOrder/sendMiddle/${id}`,
    method: 'patch',
    handleError: true,
  })
}


/**
 * 确认重新入库
 * @param data
 * @returns {Promise | Promise<unknown>}
 */
export function knowCancel(data){
  return request({
    url: `/middleWorkOrder/knowCancel`,
    method: 'put',
    data,
    handleError: true,
  })
}

/**
 * 导出拣货单
 * @param data
 * @returns {Promise | Promise<unknown>}
 */
export function exportMiddleThermalPdf(data){
  return request({
    url: `/middleWorkOrder/exportMiddleThermalPdf`,
    method: 'post',
    data,
    responseType: "arraybuffer",
    isNotJson: true,
    timeout: 60000 * 5, // 1分钟
    handleError: true,
  })
}

/**
 * 保存编辑的数据
 * @param data
 * @returns {Promise | Promise<unknown>}
 */
export function saveMiddleWorkRlGoodsNum(data){
  return request({
    url: `/middleWorkOrder/saveMiddleWorkRlGoodsNum`,
    method: 'put',
    handleError: true,
    data,
  })
}
